<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/layui/css/layui.css" media="all"/>
    <link rel="stylesheet" href="/css/news.css"/>
    <style>
        li {
            list-style: inherit !important;
        }
    </style>
</head>

<body class="childrenBody">
<form class="layui-form" action="">
    <div class="layui-form-item">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入标题" class="layui-input"
                   id="title">
        </div>
    </div>
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">小标题</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" lay-verify="required" placeholder="请输入小标题" class="layui-input"-->
                   <!--id="title2">-->
        <!--</div>-->
    <!--</div>-->
    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">封面图</label>
            <div class="layui-input-inline">
                <div class="layui-upload">
                    <div class="layui-upload-list">
                        <img class="layui-upload-img" id="mimg2">
                    </div>
                    <button type="button" class="layui-btn" id="test1"><i class="layui-icon">&#xe67c;</i>上传图片</button>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-inline">
            <label class="layui-form-label">内容图</label>
            <div class="layui-input-inline">
                <div class="layui-upload">

                    <div class="layui-upload-list" id="ula">
                        <img class="layui-upload-img" id="mimg">
                    </div>
                    <button type="button" class="layui-btn" id="test2"><i class="layui-icon">&#xe67c;</i>上传图片(多选)
                    </button>
                </div>
            </div>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品类型</label>
        <div class="layui-input-block">
            <select name="modules" lay-verify="required" id="goodsType">
                <option value="1">保税区</option>
                <option value="2">大贸商品</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">商品分类</label>
        <div class="layui-input-block">
            <select name="modules" lay-verify="required" id="goodClass">
                <option value="1">保税区</option>
                <option value="2">大贸商品</option>
            </select>
        </div>
    </div>
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">sku</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" lay-verify="required" placeholder="请输入sku" class="layui-input"-->
                   <!--id="sku">-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">标签</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input type="text" lay-verify="required" placeholder="请输入标签 例如正品保障，海外直供 英文,分割" class="layui-input"-->
                   <!--id="tag">-->
        <!--</div>-->
    <!--</div>-->
    <!--<div class="layui-form-item">-->
        <!--<label class="layui-form-label">税费</label>-->
        <!--<div class="layui-input-block">-->
            <!--<input min="0" type="number" lay-verify="required" placeholder="请输入税费" class="layui-input"-->
                   <!--id="taxPrice">-->
        <!--</div>-->
    <!--</div>-->
    <div class="layui-form-item">
        <label class="layui-form-label">价格</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="number|required" placeholder="请输入原价" class="layui-input"
                   id="price">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">原价</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="number|required" placeholder="请输入原价" class="layui-input"
                   id="originalPrice">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">商品详情</label>
        <div class="layui-input-block">
            <div id="editor"></div>
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label">库存</label>
        <div class="layui-input-block">
            <input type="text" lay-verify="required" placeholder="请输入库存" class="layui-input"
                   id="kucun">
        </div>
    </div>

    <!--<div id="appendlist2">-->
        <!--<div class="layui-form-item">-->
            <!--<label class="layui-form-label">商品规格</label>-->
            <!--<div class="layui-input-block" id="guige2">-->
                <!--<input style="width: 200px;float: left;margin-right: 10px;" type="text" name="aprice" placeholder="规格名称"-->
                       <!--class="layui-input">-->
                <!--<div class="layui-form-mid layui-word-aux">/</div>-->
                <!--<input style="width: 200px;float: left;margin-right: 15px;" type="text" name="apunit" placeholder="规格值"-->
                       <!--class="layui-input">-->
                <!--<button style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;"-->
                        <!--type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal" id="addbut2">-->
                    <!--<i style="margin-left: -3px;" class="layui-icon">&#xe654;</i></button>-->
            <!--</div>-->
        <!--</div>-->
    <!--</div>-->
    <div id="divAddAttr" style="display: none" class="layui-form-item">
        <div class="layui-input-block">
            <a class="layui-btn layui-btn-normal" id="addAttrLevel">添加一层规格</a>
            <a class="layui-btn layui-btn-primary" id="removeAttrLevel">删除一层规格</a>
        </div>
    </div>

    <div id="divAttr">
    </div>
    <!--<div id="appendlist3">-->
    <!--<div class="layui-form-item">-->
    <!--<label class="layui-form-label">商品规格</label>-->
    <!--<div class="layui-input-block" id="guige3">-->
    <!--<input  style="width: 200px;float: left;margin-right: 10px;" type="text" name="aprice" placeholder="规格名" class="layui-input">-->
    <!--<div class="layui-form-mid layui-word-aux">/</div>-->
    <!--<input  style="width: 200px;float: left;margin-right: 15px;"  type="text" name="apunit" placeholder="规格值" class="layui-input" >-->
    <!--<button style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal" id="addbut2"><i style="margin-left: -3px;" class="layui-icon">&#xe654;</i></button>-->
    <!--</div>-->
    <!--</div>-->
    <!--</div>-->

    <div class="layui-form-item">
        <div class="layui-input-block">
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="edit"
               id="edit">立即修改</a>
            <a style="display:none;" class="layui-btn layui-btn-normal" lay-submit="" lay-filter="add" id="add">立即提交</a>
            <a class="layui-btn layui-btn-primary close">关闭</a>
        </div>
    </div>
</form>
<script type="text/javascript" src="../../js/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../../layui/layui.js"></script>
<script type="text/javascript" src="../../js/wangEditor.js"></script>
<script type="text/javascript" src="../../js/basic.js"></script>
<script>
    var maxLevel = 0;


    $("#addAttrLevel").click(function () {
        if (maxLevel > 0) {
            layer.msg('最多添加1层规格', {icon: 2});
            return;
        }
        var list = [{attrName: ""}];
        addLay(maxLevel);
        addAttr(list, maxLevel);
        maxLevel++;
    });
    $("#removeAttrLevel").click(function () {
        maxLevel--;
        if (maxLevel <= 0) {
            maxLevel = 0
        }
        removieLay(maxLevel);
        //    $("#appendlist" + maxLevel).empty();


    });

    //获取商品分类
    function getClass(claaId) {
        $.ajax({
            type:"post",
            url:"/class",
            data:{},
            dataType:"json",
            success:function (data) {
                if (data.status == 0) {
                    $("#goodClass").empty();
                    var op = document.createElement("option");
                    document.getElementById("goodClass").appendChild(op);
                    for(var i =0;i<data.result.length;i++){
                        var op = document.createElement("option");
                        op.text = data.result[i].name;
                        op.value = data.result[i].id;
                        document.getElementById("goodClass").appendChild(op);
                    }
                    if (claaId){
                        $("#goodClass").val(classId);
                        begin();
                    } else {
                        layer.msg(data.msg, {icon: 1});
                    }

                }
            }

        });
    }

    function getLevelString() {
        var attrInfo = [];
        for (var level = 0; level < maxLevel; level++) {
            var attrDetail = [];
            var c2 = false;

            $("#appendlist" + level + " input").each(function () {
                if ($(this).val() == "") {
                    c2 = true;
                    return false;
                }
            });
            if (c2) {
                layer.msg('商品规格写完整', {icon: 2});
                return;
            } else {
                var child = $("#appendlist" + level).find('div[class="layui-form-item"]')
                for (var i = 1; i <= child.length; i++) {
                    var aa = $("#appendlist" + level + " div:nth-child(" + i + ") div input").val();
                    var bb = $("#appendlist" + level + " div:nth-child(" + i + ") div input:nth-child(3)").val();
                    if (bb < 0) {
                        layer.msg('请输入合法价格', {icon: 2});
                        return;
                    }
                    var a = {};
                    a.attrName = aa;
                    a.price = bb;
                    attrDetail.push(a);
                }
            }
            attrInfo.push(attrDetail);
        }
        console.log(JSON.stringify(attrInfo));
        return JSON.stringify(attrInfo);

    }

    function getLayString() {
        var layInfo = [];
        for (var level = 0; level < maxLevel; level++) {

            layInfo.push($("#attrLayName" + level).val());
        }
        return layInfo.toString();

    }

    function getAttr(levelList, layList) {
        maxLevel = levelList.length;
        console.log(maxLevel + "   " + JSON.stringify(levelList));
        for (var i = 0; i < levelList.length; i++) {
            addLay(i, layList[i]);
            addAttr(levelList[i], i);
        }
    }
    function addCoin(level) {
        num2 = $("#appendlist" + level).find('div[class="layui-form-item"]');
        var sfname = $("#appendlist" + level + " div:nth-child(" + num2.length + ") div input").val();
        var sfprice = $("#appendlist" + level + " div:nth-child(" + num2.length + ") div input:nth-child(3)").val();
        var innerHTML = "";
        if (sfname == "" || sfprice == "") {
            layer.msg('商品规格写完整再添加', {icon: 2});
        } else {
            innerHTML += '<div class="layui-form-item">';
            innerHTML += '<label class="layui-form-label"></label>';
            innerHTML += '<div class="layui-input-block">';
            innerHTML += '<input id="sfname" style="width: 200px;float: left;margin-right: 10px;" type="text" name="aprice" placeholder="规格名" class="layui-input">';
            innerHTML += '<div class="layui-form-mid layui-word-aux">/</div>';
            innerHTML += '<input id="sfprice" style="width: 200px;float: left;margin-right: 10px;" min="0" type="number" name="apunit" placeholder="附加价格" class="layui-input" >';
            innerHTML += '<div class="layui-form-mid layui-word-aux">元</div>';
            innerHTML += '<button  style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal remo"><i style="margin-left: -3px;" class="layui-icon">&#x1006;</i></button>'
            innerHTML += '</div>';
            innerHTML += '</div>';

            $("#appendlist" + level).append(innerHTML)
            intAttr();
        }
    }

    var num2 = 1;


    function addAttr(list, level) {

        $("#appendlist" + level).empty();
        var innerHTML = "";

        for (var i = 0; i < list.length; i++) {

            innerHTML += '<div class="layui-form-item">';
            if (i == 0) {
                innerHTML += '<label class="layui-form-label">规格' + (level + 1) + '层</label>';
            } else {
                innerHTML += '<label class="layui-form-label"></label>';
            }

            innerHTML += '<div class="layui-input-block">';
            innerHTML += '<input id="sfname" style="width: 200px;float: left;margin-right: 10px;" type="text" name="aprice" placeholder="规格名" value="' + list[i].attrName + '" class="layui-input">';
            innerHTML += '<div class="layui-form-mid layui-word-aux">/</div>';
            innerHTML += '<input id="sfprice" style="width: 200px;float: left;margin-right: 10px;" min="0" type="number" name="apunit" placeholder="价格" value="' + list[i].price + '" class="layui-input" >';
            innerHTML += '<div class="layui-form-mid layui-word-aux">元</div>';
            if (i == 0) {
                innerHTML += '<button style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal"    onclick="addCoin(' + level + ')" ><i style="margin-left: -3px;" class="layui-icon">&#xe654;</i></button>';
            } else {
                innerHTML += '<button  style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal remo"><i style="margin-left: -3px;" class="layui-icon">&#x1006;</i></button>'
            }
            innerHTML += '</div>';
            innerHTML += '</div>';

        }
        $("#appendlist" + level).append(innerHTML);
        console.info(innerHTML);
        intAttr();
    }


    function addLay(level, name) {
        if(!name){
            name="";
        }
        var innerHTML = '<div id="attrLay' + level + '">\n' +
            '            <div class="layui-form-item">\n' +
            '                <label class="layui-form-label">规格' + (level+1) + '层名</label>\n' +
            '                <div class="layui-input-block">\n' +
            '                    <input type="text"  value="' + name + '" placeholder="请输入规格层名"  class="layui-input"\n' +
            '                           id="attrLayName' + level + '">\n' +
            '                </div>\n' +
            '            </div>\n' +
            '            <div id="appendlist' + level + '"></div>\n' +
            '        </div>';
        $("#divAttr").append(innerHTML);
    }

    function removieLay(level) {
        $("#attrLay" + level).remove();
    }
    layui.use('upload', function () {
        var upload = layui.upload;
        //执行实例
        var uploadInst = upload.render({
            elem: '#test1',//绑定元素
            url: '/file/uploadimg', //上传接口
            method: 'post',
            done: function (data) {
                if (data.status == 0) {
                    $("#mimg2").attr('src', data.result)
                } else {
                    layer.msg(data.msg, {
                        icon: 7
                    });
                }

            }
            , error: function () {
                // console.log(res);
            }
        });

        //多图片上传
        var uploadInst = upload.render({
            elem: '#test2'
            , url: '/file/uploadimg'
            , multiple: 'post'
            , done: function (res) {
                //上传完毕
                $("#mimg").remove();
                $('#ula').append('<img src="' + res.result + '"  class="layui-upload-img" onclick="removeimg(this)">')
            }
        });

    });

    function removeimg(obj) {

        layer.confirm('删除图片', {
            btn: ['确定', '取消'] //按钮
        }, function (index) {
            $(obj).remove();
            layer.close(index);
        }, function () {

        });

    }


    function getPhoto(photoList) {
        $("#mimg").remove();
        if (!photoList) {
            return;
        }
        for (i = 0; i < photoList.length; i++) {
            $('#ula').append('<img src="' + photoList[i] + '"  class="layui-upload-img" onclick="removeimg(this)">')
        }
    }


    function getMingPhoto() {
        var attach = "";
        $('#ula img').each(function () {
            var src = $(this).attr("src") + "";
            console.log("src " + src);
            if (src) {
                attach += (src + ",");
            }
        });
        console.log("attach " + attach);
        if (attach == "undefined,") {
            return "";
        }
        if (attach) {
            attach = attach.substring(0, attach.length - 1);
        }
        return attach;
    }

    //以下是富文本编辑器
    //具体后台返回数据请查看：https://www.kancloud.cn/wangfupeng/wangeditor3/335782
    var E = window.wangEditor
    var editor = new E('#editor')

    editor.customConfig.uploadImgServer = '../../file/mulUpload'  // 上传图片到服务器


    editor.customConfig.menus = [
        'head',  // 标题
        'bold',  // 粗体
        'italic',  // 斜体
        'underline',  // 下划线
        'strikeThrough',  // 删除线
        'foreColor',  // 文字颜色
        'backColor',  // 背景颜色
        'link',  // 插入链接
        'list',  // 列表
        'justify',  // 对齐方式
        'image',  // 插入图片
        'table',  // 表格
        'video',  // 插入视频
        'code',  // 插入代码
        'undo',  // 撤销
        'redo'  // 重复
    ]


    editor.create()

    function edit() {
        if (!$("#mimg2").attr("src")) {
            layer.msg('请上传封面图', {icon: 2});
            return;
        }
        var contentPhoto = getMingPhoto();
        if (!contentPhoto) {
            layer.msg('请上传内容图', {icon: 2});
            return;
        }
        var id = GetQueryString("id");
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        var attrJson = getLevelString();
        if (attrJson == null) {
            // layer.msg('请完善规格规格', {icon: 2});
            return;
        }
        $.ajax({
            type: "post",
            url: "/goods/update",
            data: {
                title: $("#title").val(),
                title2: $("#title2").val(),
                goodsType: $("#goodsType").val(),
                sku: $("#sku").val(),
                tag: $("#tag").val(),
                taxPrice: $("#taxPrice").val(),
                originalPrice: $("#originalPrice").val(),
                detail: editor.txt.html(),
                attrJson: attrJson,
                contentPhoto: contentPhoto,
                saleNum: $("#saleNum").val(),
                facePhoto: $("#mimg2").attr("src"),
                kucun: $("#kucun").val(),
                price : $("#price").val(),
                goodsId: id
            },
            dataType: "json",
            success:

                function (data) {
                    backData(data, topM);
                }
        })
        ;
    }

    function add() {
        if (!$("#mimg2").attr("src")) {
            layer.msg('请上传封面图', {icon: 2});
            return;
        }
        var contentPhoto = getMingPhoto();
        console.log(" contentPhoto " + contentPhoto);
        if (!contentPhoto) {
            layer.msg('请上传内容图', {icon: 2});
            return;
        }
        var topM = layer.msg('数据提交中，请稍候', {icon: 16, time: false, shade: 0.8});
        var attrJson = getLevelString();
        if (attrJson == null) {
            // layer.msg('请完善规格规格', {icon: 2});
            return;
        }
        $.ajax({
            type: "post",
            url: "/goods/save",
            data: {
                title: $("#title").val(),
                title2: $("#title2").val(),
                goodsType: $("#goodsType").val(),
                sku: $("#sku").val(),
                tag: $("#tag").val(),
                taxPrice: $("#taxPrice").val(),
                originalPrice: $("#originalPrice").val(),
                attrJson: attrJson,
                status: 0,
                detail: editor.txt.html(),
                contentPhoto: contentPhoto,
                saleNum: 0,
                facePhoto: $("#mimg2").attr("src"),
                kucun: $("#kucun").val(),
                price : $("#price").val(),
            },
            dataType: "json",
            success:

                function (data) {
                    backData(data, topM);
                }
        })

    };

    function backData(data, topM) {
        if (data.status == 0) {

            setTimeout(function () {
                layer.close(topM);
                top.layer.msg("修改成功！");
                //刷新父页面
                parent.getList({});
                var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                parent.layer.close(index); //再执行关闭
            }, 500);
        } else {
            layer.close(topM);
            layer.msg(data.msg, {icon: 1});
        }
    }

    function begin() {
        var op = GetQueryString("op");
        getClass();
        if (op == "add") {
            $("#add").show();
            $("#divAddAttr").show();
            return;
        }
        if (op == "edit") {
            $("#edit").show();
            $("#divAddAttr").show();
        }
        var id = GetQueryString("id");
        $.ajax({
            type: "post",
            url: "/goods/info",
            data: {
                goodsId: id
            },
            dataType: "json",
            success: function (data) {
                if (data.status == 0) {
                    $("#id").val(data.result.id);
                    $("#createTime").val(data.result.createTime);
                    $("#title").val(data.result.title);
                    $("#title2").val(data.result.title2);
                    $("#goodsType").val(data.result.goodsType);
                    $("#sku").val(data.result.sku);
                    $("#tag").val(data.result.tag);
                    $("#taxPrice").val(data.result.taxPrice);
                    $("#originalPrice").val(data.result.originalPrice);
                    editor.txt.html(data.result.detail)
                    getPhoto(data.result.photoList);
                    $("#saleNum").val(data.result.saleNum);
                    $("#mimg2").attr("src", data.result.facePhoto);
                    $("#kucun").val(data.result.kucun);
                    addAttr(data.result.attrJson);
                    layui.form.render();

                } else {
                    layer.msg(data.msg, {icon: 1});
                }
            }
        });
    }

    //点击取消关闭当前弹窗
    $(".close").click(function () {
//当你在iframe页面关闭自身时
        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
        parent.layer.close(index); //再执行关闭
    })

    layui.use(['form'], function () {
        var form = layui.form;
        //监听提交
        form.on('submit(add)', function (data) {
            add()
            return false;
        });

        //监听提交
        form.on('submit(edit)', function (data) {
            edit()
            return false;
        });
        begin();
        intAttr();
    });


    function getAttrJson() {

        var attrObj = [];
        var c2 = false;

        $("#appendlist2 input").each(function () {

            if ($(this).val() == "") {
                // layer.msg('请填写规格', {icon: 2});

                c2 = true;
                return false;
            }
        });
        console.log(c2);
        if (c2) {
            layer.msg('请填写完整规格', {icon: 2});

            console.log('2');
            return;
        } else {
            var child = $("#appendlist2").find('div[class="layui-form-item"]')
            for (var i = 1; i <= child.length; i++) {
                var aa = $("#appendlist2 div:nth-child(" + i + ") div input").val();
                var bb = $("#appendlist2 div:nth-child(" + i + ") div input:nth-child(3)").val();

                var data = {};
                data.name = aa;
                data.value = bb;
                attrObj.push(data);
            }
        }
        return JSON.stringify(attrObj);
    }

    function intAttr() {
        $(".remo").click(function () {
            $(this).parent().parent().remove();
        })


        $("#addbut2").click(function () {
            num2 = $("#appendlist2").find('div[class="layui-form-item"]');
            var sfname = $("#appendlist2 div:nth-child(" + num2.length + ") div input").val();
            var sfprice = $("#appendlist2 div:nth-child(" + num2.length + ") div input:nth-child(3)").val();
            var innerHTML = "";
            if (sfname == "" || sfprice == "") {
                layer.msg('商品规格写完整再添加', {icon: 2});
            } else {
                innerHTML += '<div class="layui-form-item">';
                innerHTML += '<label class="layui-form-label"></label>';
                innerHTML += '<div class="layui-input-block">';
                innerHTML += '<input  style="width: 200px;float: left;margin-right: 10px;" type="text"  placeholder="规格名" class="layui-input">';
                innerHTML += '<div class="layui-form-mid layui-word-aux">/</div>';
                innerHTML += '<input  style="width: 200px;float: left;margin-right: 10px;" type="text"  placeholder="规格值" class="layui-input" >';
                innerHTML += '<button  style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal remo"><i style="margin-left: -3px;" class="layui-icon">&#x1006;</i></button>'
                innerHTML += '</div>';
                innerHTML += '</div>';

                $("#appendlist2").append(innerHTML)
                $(".remo").click(function () {
                    $(this).parent().parent().remove();
                })
            }
        })
    }


    var num2 = 1;

    // function addAttr(attrJson) {
    //     console.info("attrJson" + attrJson);
    //     var attrObj = eval('(' + attrJson + ')');
    //     $("#appendlist2").empty();
    //     var innerHTML = "";
    //
    //     for (var i = 0; i < attrObj.length; i++) {
    //
    //         innerHTML += '<div class="layui-form-item">';
    //         if (i == 0) {
    //             innerHTML += '<label class="layui-form-label">商品规格</label>';
    //         } else {
    //             innerHTML += '<label class="layui-form-label"></label>';
    //         }
    //
    //         innerHTML += '<div class="layui-input-block">';
    //         innerHTML += '<input id="sfname" style="width: 200px;float: left;margin-right: 10px;" type="text"  placeholder="规格名" value="' + attrObj[i].name + '" class="layui-input">';
    //         innerHTML += '<div class="layui-form-mid layui-word-aux">/</div>';
    //         innerHTML += '<input id="sfprice" style="width: 200px;float: left;margin-right: 10px;"  type="text"  placeholder="规格值" value="' + attrObj[i].value + '" class="layui-input" >';
    //         if (i == 0) {
    //             innerHTML += '<button style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal" id="addbut2"><i style="margin-left: -3px;" class="layui-icon">&#xe654;</i></button>';
    //         } else {
    //             innerHTML += '<button  style="margin-top: 4px;text-align: center;text-align: center;width: 30px;height: 30px;line-height: 30px;" type="button" class="layui-btn layui-btn-small layui-btn-radius layui-btn-normal remo"><i style="margin-left: -3px;" class="layui-icon">&#x1006;</i></button>'
    //         }
    //         innerHTML += '</div>';
    //         innerHTML += '</div>';
    //     }
    //     $("#appendlist2").append(innerHTML)
    //     console.info(innerHTML);
    //     intAttr();
    // }


</script>
</body>
</html>